/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package xq.gwt.ui.widgets.property;

import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.Label;
import xq.gwt.mvc.controller.TextPropertyController;
import xq.gwt.mvc.model.PropertyModel;
import xq.gwt.mvc.view.ObservableViewImp;
import xq.gwt.mvc.view.TextPropertyView;

/**
 *
 * @author admin
 */
public class LabelPropertyPresenter extends ObservableViewImp implements TextPropertyView{
    protected Label label;
	protected TextPropertyController controller;	

    public LabelPropertyPresenter(Label label){        
    	this.label = label;    	
        init();
        
    }
    
    public LabelPropertyPresenter(){    	
    	label = new Label();   	
    	init();
    }

	protected void init() {				
		controller = new TextPropertyController(this);		
	}
    
    public void setText(String text) {
        label.setContents(text);        
    }

    public String getText() {
    	if(label.getTitle() == null)
    		return null;
        return String.valueOf(label.getTitle());
    }
    
    public void setModel(PropertyModel model){    	
    	controller.setPropertyModel(model);
    }
        
    

    public Label getLabel() {
		return label;
	}

    public Canvas getCanvas(){
    	return label;
    }
    
	@Override
    public void setEnabled(boolean enabled) {
    	    	
    }

	@Override
	public void setError(String errorMessage) {		
		
	}

	@Override
	public void clearError() {		
		
	}

	@Override
	public void setRequired(boolean required) {
		
		
	}

	@Override
	public void setName(String name) {
		
	}

	@Override
	public void setTitle(String title) {		
		
	}
}
